package crm.view.statistic;

import javax.swing.event.TreeModelListener;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;

import crm.model.teacherPC.Manager;
import crm.model.teacherPC.net.StudentPC;

public class StatisticTreeModel implements TreeModel{
	Manager manager;
	public StatisticTreeModel(Manager manager){
		this.manager=manager;
	}

	@Override
	public Object getChild(Object parent, int index) {
		if (parent instanceof Manager){
			Manager manager = (Manager)parent;
			return manager.getStudent(index);
		}else if (parent instanceof StudentPC){
			StudentPC student = (StudentPC)parent;
			return student.statistic;
		}
		return null;
	}

	@Override
	public int getChildCount(Object parent) {
		if (parent instanceof Manager){
			Manager manager = (Manager)parent;
			return manager.getStudentCount();
		}else if (parent instanceof StudentPC){
			return 1;
		}
		return 0;
	}

	@Override
	public int getIndexOfChild(Object parent, Object child) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public Object getRoot() {
		// TODO Auto-generated method stub
		return manager;
	}

	@Override
	public boolean isLeaf(Object node) {
		// TODO Auto-generated method stub
		return getChildCount(node) == 0;
	}

	@Override
	public void removeTreeModelListener(TreeModelListener l) {
		// TODO Auto-generated method stub

	}

	@Override
	public void addTreeModelListener(TreeModelListener l) {
		// TODO Auto-generated method stub

	}
	@Override
	public void valueForPathChanged(TreePath path, Object newValue) {
		// TODO Auto-generated method stub

	}

}
